<?php
function generate_cat_url($cat = array()){
    if($cat){
        return '/'.$cat['cat_name'].'-'.$cat['cat_id'].'.chn';
    }else{
        return '/phan-mem/';
    }

}

function generate_product_detail_url($products) {
    return '/phan-mem/' .removeTitle($products['pro_name']). '-' .$products['pro_id']. '.html';
}

function generate_tutorials_detail_url($tut) {
    return '/huong-dan/' .removeTitle($tut['tut_title']). '-' .$tut['tut_id']. '.html';
}
function generate_tutorials_cat_url($tut){
    return '/huong-dan/'.removeTitle($tut['cat_name']).'-'.$tut['cat_id'].'/';
}

function removeTitle($string,$keyReplace = "/"){
	 $string = removeSign($string);
	 $string  =  trim(preg_replace("/[^A-Za-z0-9]/i"," ",$string)); // khong dau
	 $string  =  str_replace(" ","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace($keyReplace,"-",$string);
	 return strtolower($string);
}
?>